package com.lw.leetcode.test.lfu;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @Author liw
 * @Date 2021/3/24 13:17
 * @Version 1.0
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Node<K, V> implements Comparable<Node<K, V>> {
    private K key;
    private V value;
    private long time;
    private int count;

    @Override
    public int compareTo(Node o) {
        if (o == null) {
            return -1;
        }
        int compare = Integer.compare(this.count, o.count);
        if (compare == 0) {
            return Long.compare(this.time, o.getTime());
        }
        return compare;
    }
}
